package com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.entity.vo.SmsAssetFixedBorrowApplyAllowVO;
import com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.entity.vo.SmsAssetFixedBorrowApplyVO;
import com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.service.SmsAssetFixedBorrowApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-05-29
 */
@RestController
@RequestMapping("/smsAssetFixedBorrowApply")
@SecretBody
public class SmsAssetFixedBorrowApplyController {
    @Autowired
    SmsAssetFixedBorrowApplyService smsAssetFixedBorrowApplyService;
    @Autowired
    JwtTokenUtil jwtTokenUtil;
    @ApiModelProperty(value = "新增固定资产借用申请")
    @PostMapping("/add")
    public ResponseResult smsAssetFixedBorrowApplyAdd(@RequestBody SmsAssetFixedBorrowApplyVO applyVO,
                                                   HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetFixedBorrowApplyService.smsAssetFixedBorrowApplyAdd(applyVO,user_id);
    }
    @ApiModelProperty(value = "撤销借用申请")
    @PostMapping("/cancel")
    public ResponseResult smsAssetFixedBorrowApplyCancel(@RequestBody SmsAssetFixedBorrowApplyVO cancelVO,
                                                         HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetFixedBorrowApplyService.smsAssetFixedBorrowApplyCancel(cancelVO,user_id);
    }
    @ApiModelProperty(value = "审批")
    @PostMapping("/allow")
    public ResponseResult smsAssetFixedBorrowApplyAllow(@RequestBody SmsAssetFixedBorrowApplyAllowVO allowVO,
                                                        HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetFixedBorrowApplyService.smsAssetFixedBorrowApplyAllow(allowVO,user_id);
    }
    @ApiModelProperty(value = "审批列表")
    @GetMapping("/list")
    public ResponseResult getAssetFixedBorrowApplyList(@RequestParam (value = "pageSize",defaultValue = "10") Integer pageSize,
                                                       @RequestParam (value = "pageNum",defaultValue = "1") Integer pageNum,
                                                       @RequestParam (value = "apply_type")Integer apply_type,
                                                       HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetFixedBorrowApplyService.getAssetFixedBorrowApplyList(pageSize,pageNum,apply_type,user_id);
    }
    @ApiModelProperty(value = "审批详情")
    @GetMapping("/detail")
    public ResponseResult getAssetFixedBorrowApplyDetail(@RequestParam(value = "apply_id") String apply_id,
                                                         HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetFixedBorrowApplyService.getAssetFixedBorrowApplyDetail(apply_id,user_id);
    }
    @ApiModelProperty(value = "查询所有申请记录")
    @GetMapping("/selectAll")
    public ResponseResult selectAllAssetFixedBorrowApply(
            @RequestParam(value = "apply_person",required = false) String apply_person,
            @RequestParam(value = "apply_department",required = false) String apply_department,
            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum
            ){
        return smsAssetFixedBorrowApplyService.selectAllAssetFixedBorrowApply(apply_person,
                apply_department,pageSize,pageNum);
    }
    @ApiModelProperty(value = "根据id查申请记录查询")
    @GetMapping("/selectDetail")
    public ResponseResult selectDetail(@RequestParam(value = "id",required = false) String id){
        return smsAssetFixedBorrowApplyService.selectDetail(id);
    }
    @ApiModelProperty(value = "查询具体资产")
    @GetMapping("/select")
    public ResponseResult select(@RequestParam(value = "goodsId",required = false) String goodsId){
        return smsAssetFixedBorrowApplyService.select(goodsId);
    }

}

